home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 April: Mac OS SDK / Dev.CD Apr 97 SDK1.toast / Development Kits (Disc 1) / AppleScript / Sample Scripts / AppleScript Samples / Numerics / Round Off Example < prev    next >
Encoding:
Text File  |  1993-12-08  |  640 b   |  11 lines  |  [TEXT/ToyS]

  1. set x to (("9776.552" as real) as string) -- string to real to string 
  2. -- the previous line shows how the number changes as it is coerced to a real
  3. set y to "9776.552" -- this is the original string
  4. 9776.5519999999997 -- watch this when you compile it!  It no longer is 9776.552
  5. -- the following displays values in the result window
  6. -- x is the converted string, y is the original string
  7. -- x = y is a string comparision, while the next one is a pair of reals
  8. -- Finally, an example of how two numbers which don't suffer from round off
  9. -- can equal one that does
  10. {x, y, x = y, (x as real) = (y as real), 76.552 + 9700 = 9776.5519999999997}
  11.